a = "Wrong input"
def prime(n):
    if n%2 == 0:
        return False
    for i in range(2, n//2 +2):
        if n%i == 0:
            return False
    return True
    
def ans(n, a):
    if b ==1:
        return a
    else:
        maxn = n
        minn = n
        if prime(n) == True:
            return n
        else:
            while True:
                if prime(minn) == True:
                    return minn
                elif prime(maxn) == True:
                    return maxn
                else:
                    maxn += 1
                    minn -= 1
                    
        

num = input()
nums = num.split()
b = 0
number = 0
le = len(nums)
for i in range(0, le):
    if nums[i] != "zero" and nums[i] != "one" and nums[i] != "two" and nums[i] != "three" and nums[i] != "four" and nums[i] != "five" and nums[i] != "six" and nums[i] != "seven" and nums[i] != "eight" and nums[i] != "nine":
        b = 1
    else:
        if nums[i] == "zero":
            number = number*10 + 0
        elif nums[i] == "one":
            number = number*10 + 1
        elif nums[i] == "two":
            number = number*10 + 2
        elif nums[i] == "three":
            number = number*10 + 3
        elif nums[i] == "four":
            number = number*10 + 4
        elif nums[i] == "five":
            number = number*10 + 5
        elif nums[i] == "six":
            number = number*10 + 6
        elif nums[i] == "seven":
            number = number*10 + 7
        elif nums[i] == "eight":
            number = number*10 + 8
        elif nums[i] == "nine":
            number = number*10 + 9
print(ans(number, a))